cfRSetVar('extensionFilter',false); // array of extensions of displayed files. Set to false if no filter on file extension
cfRSetVar('fileTypeFilter',array('audio'));// array of file types of displayed files. Set to false if no filter on file type (see mime_type.php for list of file types)
cfRSetVar('playlistDisplayed',true); // Show main playlist
cfRSetVar('needAudioInfo',true); // Indicate efGetDirContent to get id3 info
cfRInitVar('sortField','no'); // Files grouping
cfRSetVarArray('playlist'); // Reset main playlist
// extAccessFunction used to check file rights in /ext/audio.php
sqlite_query('INSERT INTO playlistsTracks SELECT tmp.PlaylistID as PlaylistID, tracks.id as TrackId FROM playlistsTemp AS tmp INNER JOIN tracks ON tmp.TrackFilename=tracks.Location',$db);
//dbDisplayTable('tracks');exit;
// Close DB
@sqlite_close($db);
if($debug) cfAppendTextToFile('Commit to DB...',cfAppRootDir().'/musicLog.txt');
sqlite_single_query('BEGIN TRANSACTION;DELETE FROM library;DELETE FROM tracks;DELETE FROM playlists;DELETE FROM playlistsTracks;DELETE FROM playlistsTemp;COMMIT',$db);
if(substr($_POST['data2'],0,1)=='=') $_POST['data2']=substr($_POST['data2'],1); // if search arg starts by '=', don't add wildcards
elseif(strpos($_POST['data2'],'*')===false && strpos($_POST['data2'],'?')===false) $_POST['data2']='*'.$_POST['data2'].'*'; // else if no wildcard or ?; add * at start and end of search
$tracks=sqlite_array_query("SELECT * FROM tracks WHERE Lower(Artist)='".strtolower(sqlite_escape_string($artist))."' AND Lower(Album)='".strtolower(sqlite_escape_string($album))."' LIMIT 200",$db,SQLITE_ASSOC);
foreach ($tracks as $k=>$v) $tracks[$k]=mDBPlaylistItemFromTrack($v);
cfRSetVar('playlistTmp',$tracks);
}
// If not playlist, artist or album, it's a track, identified by it's numerical id
// else, select artwork from other tracks from same artist/album
else $art=sqlite_single_query('SELECT max(Artwork) FROM tracks WHERE Artist="'.sqlite_escape_string($artistName).'" AND Album="'.sqlite_escape_string($albumName).'"',$db);
// If iTunes, add itc extension (not stored into db)
if(SOURCE_TYPE=='iTunes') $op='max'; else $op='min'; // iTunes needs to get highest value as it contains empty elements, other need lowest as values are folderXXX or embedXXX, and embed is prefered over folder
sqlite_query("CREATE VIEW tmpArtist AS SELECT max(Artist) as Artist, max(Album) AS Album, count(id) AS nbTracks, ".$op."(Artwork) AS art FROM tracks ".(($filter===false)?"":$filter." ")."GROUP BY lower(Album),lower(Artist);",$db);
$list=sqlite_array_query("SELECT min(Artist) AS Artist, count(Album) AS nbAlbums, sum(nbTracks) AS nbTracks, ".$op."(art) AS art FROM tmpArtist GROUP BY lower(Artist) ORDER BY lower(Artist) ASC",$db,SQLITE_ASSOC);
// Count results to detect result-less search request
// iTunes needs to get highest value as it contains empty elements, other need lowest as values are folderXXX or embedXXX, and embed is prefered over folder
$list=sqlite_array_query("SELECT min(Album) AS Album, min(Artist) AS Artist, ".$op."(Artwork) AS art, count(*) AS nbTracks, sum(TotalTime) AS totalTime FROM tracks ".(($filter===false)?'':$filter.' ')."GROUP BY lower(Album), lower(Artist) ORDER BY lower(Artist) ASC",$db,SQLITE_ASSOC);
// Count results to detect result-less search request
* @desc Return displayType('compact'), playlist data array, select list array, current offset
* @return string : "display type, Array(Array('PlaylistID','PlaylistName',nbTracks1),...), Array(...), current offset
*/
function groupByPlaylistData($filter=false){
global $db;
$list=sqlite_array_query("SELECT playlists.playlistId AS PlaylistID, playlists.Name AS PlaylistName, count(*) AS nbTracks FROM playlists INNER JOIN playlistsTracks ON playlists.PlaylistID=playlistsTracks.PlaylistID ".(($filter===false)?'':$filter.' ')."GROUP BY playlists.playlistId",$db);
// Count results to detect result-less search request
$list=sqlite_array_query("SELECT id, name, totalTime, Album, Artist FROM tracks ".(($filter===false)?'':$filter.' ')."GROUP BY lower(Album), lower(Artist), name ORDER BY lower(Album) ASC".((cfRGetVar('itemsPerPage'))?" LIMIT ".cfRGetVar('itemsPerPage'):''),$db,SQLITE_ASSOC);
$filter='';
// Count results to detect result-less search request
$list=sqlite_array_query("SELECT Album, id, PersistentId, Name, Artwork, Year, TotalTime FROM tracks WHERE lower(Artist)='".strtolower(sqlite_escape_string($artistName))."' ORDER BY lower(Album) ASC, TrackNumber ASC",$db,SQLITE_ASSOC);
$list=sqlite_array_query("SELECT Album, id, Name, TrackNumber, TotalTime FROM tracks WHERE lower(Artist)='".strtolower(sqlite_escape_string($artistName))."' AND lower(Album)='".strtolower(sqlite_escape_string($albumName))."' ORDER BY TrackNumber ASC",$db);
* Array(Track1 ID, Track1 name, Track1 total time, Track1 artist, Track1 album),
* Array(Track2 ID, Track2 name, Track2 total time, Track2 artist, Track2 album),
* ...
* ),
* )
*/
function showDetailPlaylist($playlistId, $destId){
global $db;
$list=sqlite_array_query("SELECT t.id AS id, t.Artist AS Artist, t.Album AS Album, t.Name AS Name, t.TotalTime AS TotalTime FROM playlistsTracks pt INNER JOIN tracks t ON t.id=pt.trackId WHERE pt.PlaylistID='".$playlistId."'",$db);
$list=sqlite_array_query("SELECT id, Artist, Album, TrackNumber, Name FROM tracks WHERE lower(Artist)='".sqlite_escape_string($itemId)."' ORDER BY lower(Artist) ASC, lower(Album) ASC, TrackNumber ASC",$db);
$list=sqlite_array_query("SELECT id, Artist, Album, TrackNumber, Name FROM tracks WHERE lower(Artist)='".sqlite_escape_string($itemId)."' AND lower(Album)='".sqlite_escape_string($albumName)."' ORDER BY lower(Artist) ASC, lower(Album) ASC, TrackNumber ASC",$db);
$list=sqlite_array_query("SELECT t.id AS id, t.Artist AS Artist, t.Album AS Album, t.TrackNumber AS TrackNumber, t.Name AS NAME FROM tracks t INNER JOIN playlistsTracks pt ON t.id=pt.TrackID WHERE pt.PlaylistID='".sqlite_escape_string($itemId)."'",$db);
$list=sqlite_array_query("SELECT id, Artist, Album, TrackNumber, Name FROM tracks ORDER BY Random() LIMIT ".max(1,cfRGetVar('plAddAllShuffleSize')),$db);
foreach ($displayTypes as $dt=>$icon) $output.=outBlockItem('displayType',outImage('/gfx/'.$icon),false,'padding:10px',array('onclick'=>'changeDisplayType(\''.$dt.'\')'),(cfRGetVar('displayType')==$dt)?'sel':'unsel');
$filter="WHERE lower(Artist) LIKE '".strtolower(sqlite_escape_string(((cfRGetVar('searchValue')==cfCaption('explorerAudioUnknownArtist'))?'':cfRGetVar('searchValue'))))."'";
$filter="WHERE (lower(Artist) NOT LIKE '".strtolower(sqlite_escape_string(cfRGetVar('searchValue')))."') AND (lower(Album) LIKE '".sqlite_escape_string(strtolower(((cfRGetVar('searchValue')==cfCaption('explorerAudioUnknownAlbum'))?'':cfRGetVar('searchValue'))))."')";
$filter="WHERE (lower(Artist) NOT LIKE '".sqlite_escape_string(strtolower(cfRGetVar('searchValue')))."') AND (lower(Album) NOT LIKE '".sqlite_escape_string(strtolower(cfRGetVar('searchValue')))."') AND (lower(Name) LIKE '".sqlite_escape_string(strtolower(cfRGetVar('searchValue')))."')";
//dbDisplayTable('SELECT Album from tracks GROUP BY Album;');
//@sqlite_query('CREATE VIEW artAlb AS SELECT Artist, Album, count(id) AS nbTracks, (min(Artwork || PersistentID)) AS art FROM tracks GROUP BY Artist, Album;',$db);
//dbDisplayTable('SELECT * FROM artAlb');
//dbDisplayTable('SELECT Artist, sum(nbTracks) AS nbTracks2, count(Album) AS nbAlbums FROM artAlb WHERE lower(Artist) < \'benabar\' GROUP BY Artist ORDER BY lower(Artist) ASC;');
var supportsPlaylist=<?php echo (int)(cfBGetVar('playlistFormat'));?>;
var margins=<?php if(cfGetBrowser()=='ie') echo 20; else echo 25;?>;
var lPID="<?php echo cfRGetVar('Library Persistent ID');?>";
var coverTemplate="<?php echo cfExtImage('*resourceBasePath*/IMAGEPATH',FULLVIEW_COVER_WIDTH,FULLVIEW_COVER_WIDTH,true,0,array('utf8Decode'=>true),true);?>";
var hmsCaption="<?php echo cfCaptionJS('javascriptHourMinSecFormat');?>";
var msCaption="<?php echo cfCaptionJS('javascriptMinSecFormat');?>";
var sourceType="<?php echo SOURCE_TYPE;?>";
var maxDragItems=<?php echo cfHiGetVar('maxDragItems',80);?>;
var searchValue;
var coverDefaultSrc='<?php echo dirname($_SERVER['PHP_SELF']);?>/../music2/cover.png';
var dAWW=<?php echo DEFAULT_AUDIO_WINDOW_WIDTH;?>, dAWH=<?php echo DEFAULT_AUDIO_WINDOW_HEIGHT;?>,fCW=<?php echo FULLVIEW_COVER_WIDTH;?>;